package cn.kevenpotter.leetcode.easy.e27;

public class RemoveElement {

    public static void main(String[] args) {
        System.out.println(removeElement(new int[]{3, 2, 2, 3}, 3));
    }

    public static int removeElement(int[] nums, int val) {
        int length = nums.length;
        if (length == 0) return 0;
        int slowPointer = 0;
        for (int fastPointer = 0; fastPointer < length; fastPointer++) {
            if (nums[fastPointer] != val) {
                nums[slowPointer++] = nums[fastPointer];
            }
        }
        return slowPointer;
    }
}
